import instance from '@/utils/request'
import Qs from 'qs'
/**
 * 分页查询
 */
export const userPage = (entity) => {
  return instance.get('/user/page?' + Qs.stringify(entity))
}

/**
 * 根据 code 查询 对象
 */
export const usergetById = (id) => {
  return instance.get('/user/getById?' + Qs.stringify(id))
}

/**
 * 新增
 */
export const userSave = (entity) => {
  return instance.post('/user/save', Qs.stringify(entity))
}

/**
 * 修改
 */
export const userUpdateById = (entity) => {
  return instance.post('/user/updateById', Qs.stringify(entity))
}

/**
 * 批量删除
 */
export const userBatchDelete = (nos) => {
  return instance.get('/user/deletes?nos=' + nos)
}

/**
 * 根据no删除
 */
export const userRemoveById = (no) => {
  return instance.get('/user/removeById?no=' + no)
}

/**
 * 根据 name、no 查询角色名称是否唯一
 */
export const selectOneByUserName = (username, id) => {
  return instance.get(`/user/selectOneByUserName?username=${username}&id=${id}`)
}

/**
 * 根据 id 修改密码
 */
export const updatePassswordById = (entity) => {
  return instance.post('/user/updatePasssword', Qs.stringify(entity))
}

/**
 * 根据 id 修改 状态
 */
export const updateEnableById = (id, enabled) => {
  return instance.get(`/user/updateEnableById?id=${id}&enabled=${enabled}`)
}

/**
 * 校验旧密码、修改新密码
 */
export const changePassword = (entity) => {
  return instance.post('/user/changePassword', Qs.stringify(entity))
}
